home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / common / ui / ConsoleDlg.gui < prev    next >
Encoding:
Text File  |  2005-11-23  |  6.1 KB  |  219 lines

  1. //--- OBJECT WRITE BEGIN ---
  2. new GuiControl(ConsoleDlg) {
  3.    profile = "GuiDefaultProfile";
  4.    horizSizing = "right";
  5.    vertSizing = "bottom";
  6.    position = "0 0";
  7.    extent = "640 480";
  8.    minExtent = "8 2";
  9.    visible = "1";
  10.  
  11.    new GuiWindowCtrl(ConsoleDlgWindow) {
  12.       profile = "GuiWindowProfile";
  13.       horizSizing = "right";
  14.       vertSizing = "bottom";
  15.       position = "0 0";
  16.       extent = "500 300";
  17.       minExtent = "8 2";
  18.       visible = "1";
  19.       text = "Console";
  20.       maxLength = "255";
  21.       resizeWidth = "1";
  22.       resizeHeight = "1";
  23.       canMove = "1";
  24.       canClose = "1";
  25.       canMinimize = "0";
  26.       canMaximize = "1";
  27.       MinSize = "500 300";
  28.       closeCommand = "ToggleConsole(1);";
  29.  
  30.       new GuiScrollCtrl() {
  31.          profile = "GuiScrollProfile";
  32.          horizSizing = "width";
  33.          vertSizing = "height";
  34.          position = "3 36";
  35.          extent = "494 246";
  36.          minExtent = "8 2";
  37.          visible = "1";
  38.          willFirstRespond = "1";
  39.          hScrollBar = "alwaysOn";
  40.          vScrollBar = "alwaysOn";
  41.          constantThumbHeight = "0";
  42.          childMargin = "0 0";
  43.             resizeWidth = "1";
  44.             resizeHeight = "1";
  45.  
  46.          new GuiConsole() {
  47.             profile = "GuiConsoleProfile";
  48.             position = "0 0";
  49.          };
  50.       };
  51.       new GuiConsoleEditCtrl(ConsoleEntry) {
  52.          profile = "GuiTextEditProfile";
  53.          horizSizing = "width";
  54.          vertSizing = "top";
  55.          position = "3 278";
  56.          extent = "494 18";
  57.          minExtent = "8 2";
  58.          visible = "1";
  59.          altCommand = "ConsoleEntry::eval();";
  60.          maxLength = "255";
  61.          historySize = "20";
  62.          password = "0";
  63.          tabComplete = "0";
  64.          sinkAllKeyEvents = "1";
  65.          useSiblingScroller = "1";
  66.       };
  67.       new GuiPaneControl(ConsoleErrorPane) {
  68.          profile = "GuiPaneProfile";
  69.          horizSizing = "width";
  70.          vertSizing = "bottom";
  71.          position = "3 22";
  72.          extent = "474 85";
  73.          minExtent = "474 10";
  74.          visible = "1";
  75.          caption = "No script compilation errors occured.";
  76.          collapsable = "1";
  77.          barBehindText = "1";
  78.  
  79.          new GuiScrollCtrl(ConsoleErrorScroller) {
  80.             profile = "GuiScrollProfile";
  81.             horizSizing = "width";
  82.             vertSizing = "bottom";
  83.             position = "0 14";
  84.             extent = "474 71";
  85.             minExtent = "8 2";
  86.             visible = "0";
  87.             willFirstRespond = "0";
  88.             hScrollBar = "alwaysOff";
  89.             vScrollBar = "alwaysOn";
  90.             constantThumbHeight = "1";
  91.             childMargin = "0 0";
  92.  
  93.             new GuiMLTextCtrl(ConsoleErrorDisplay) {
  94.                profile = "GuiMLTextProfile";
  95.                horizSizing = "width";
  96.                vertSizing = "bottom";
  97.                position = "2 2";
  98.                extent = "474 14";
  99.                minExtent = "8 2";
  100.                visible = "1";
  101.                lineSpacing = "2";
  102.                allowColorChars = "0";
  103.                maxChars = "-1";
  104.             };
  105.          };
  106.       };
  107.    };
  108. };
  109. //--- OBJECT WRITE END ---
  110.  
  111. function ConsoleDlg::onWake()
  112. {
  113.    %position = $pref::Console::position;
  114.    if(%position $= "")
  115.       %position = ConsoleDlgWindow.position;
  116.    
  117.    %extent = $pref::Console::extent;
  118.    if(getWord(%extent, 0) < getWord(ConsoleDlgWindow.minExtent, 0) ||
  119.       getWord(%extent, 1) < getWord(ConsoleDlgWindow.minExtent, 1))
  120.       %extent = ConsoleDlgWindow.extent;
  121.    
  122.    ConsoleDlgWindow.resize(getWord(%position, 0), getWord(%position, 1),
  123.                            getWord(%extent, 0),   getWord(%extent, 1));
  124. }
  125.  
  126. function ConsoleDlg::onSleep()
  127. {
  128.    $pref::Console::position = ConsoleDlgWindow.position;
  129.    $pref::Console::extent = ConsoleDlgWindow.extent;
  130. }
  131.  
  132. function ConsoleEntry::eval()
  133. {
  134.    %text = trim(ConsoleEntry.getValue());
  135.  
  136.    if(strpos(%text, "(") == -1)
  137.    {
  138.       if(strpos(%text, "=") == -1 && strpos(%text, " ") == -1)
  139.       {
  140.          if(strpos(%text, "{") == -1 && strpos(%text, "}") == -1)
  141.          {
  142.             %text = %text @ "()";
  143.          }
  144.       }
  145.    }
  146.  
  147.    %pos = strlen(%text) - 1;
  148.    if(strpos(%text, ";", %pos) == -1 && strpos(%text, "}") == -1)
  149.    {
  150.       %text = %text @ ";";
  151.    }
  152.  
  153.    echo("==>" @ %text);
  154.    eval(%text);
  155.    ConsoleEntry.setValue("");
  156.  
  157.    // Check for any pending errors to display
  158.    updateConsoleErrorWindow();
  159. }
  160.  
  161. function ToggleConsole(%make)
  162. {
  163.    if (%make)
  164.    {
  165.       if (ConsoleDlg.isAwake())
  166.       {
  167.          // Deactivate the console.
  168.          
  169.          if ( $enableDirectInput )
  170.             activateKeyboard();
  171.          Canvas.popDialog(ConsoleDlg);
  172.       }
  173.       else
  174.       {
  175.          if ( $enableDirectInput )
  176.             deactivateKeyboard();
  177.          Canvas.pushDialog(ConsoleDlg, 99);
  178.  
  179.          // Check for any pending errors to display
  180.          updateConsoleErrorWindow();
  181.          
  182.           // Collapse the errors if this is the first time...
  183.          if(ConsoleErrorPane._initialized == false)
  184.             ConsoleErrorPane.setCollapsed(true);
  185.       }
  186.    }
  187. }
  188.  
  189. // The first hash is 1000...
  190. $ScriptErrorHashDisplayed = 999;
  191.  
  192. function updateConsoleErrorWindow()
  193. {
  194.    if($ScriptErrorHash != $ScriptErrorHashDisplayed && $ScriptErrorHash != 0)
  195.    {
  196.       // Hash was different so there must be a new error. Update the display!
  197.  
  198.       %oldText = ConsoleErrorDisplay.getText();
  199.       
  200.       if(%oldText !$= "")
  201.           ConsoleErrorDisplay.setText(%oldText @ "\n" @ $ScriptError);
  202.       else
  203.           ConsoleErrorDisplay.setText($ScriptError);
  204.       
  205.       ConsoleErrorDisplay.setCursorPosition(100000); // Hacka hacka hacka
  206.       ConsoleErrorDisplay.scrollToBottom();
  207.       
  208.       // Update the pane caption.
  209.       $ConsoleErrorCount += $ScriptErrorHash - $ScriptErrorHashDisplayed;
  210.       ConsoleErrorPane.caption = $ConsoleErrorCount @ " script compilation error(s) have occured!";
  211.       
  212.       // Indicate we dealt with this...
  213.       $ScriptErrorHashDisplayed = $ScriptErrorHash;
  214.       $ScriptError = "";
  215.    }
  216. }
  217.  
  218.  
  219.